package com.zenkeeuk.bookerfornfc.client.android.book;

import org.json.JSONException;
import org.json.JSONObject;

public class DoubanBookComment {
	
	private String id;
	private String title;
	private String author;
	private String summary;
	private double rating;
	
	public void setId(String id) {
		this.id = id;
	}
	public String getId() {
		return id;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getTitle() {
		return title;
	}
	public void setAuthor(String author) {
		this.author = author;
	}
	public String getAuthor() {
		return author;
	}
	public void setSummary(String summary) {
		this.summary = summary;
	}
	public String getSummary() {
		return summary;
	}
	public void setRating(double rating) {
		this.rating = rating;
	}
	public double getRating() {
		return rating;
	}
	
	public DoubanBookComment() {
		
	}
	
	public DoubanBookComment(JSONObject obj) {
		try {
			this.id = obj.getJSONObject("id").getString("$t");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		try {
			this.title = obj.getJSONObject("title").getString("$t");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		try {
			this.author = obj.getJSONObject("author").getJSONObject("name").getString("$t");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		try {
			this.summary = obj.getJSONObject("summary").getString("$t").trim();
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		try {
			this.rating = obj.getJSONObject("gd:rating").getDouble("@value");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
